package com.woniuxy.carlife.carlifeuserweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifeuserweb.entity.Cardisplacement;
import com.woniuxy.carlife.carlifeuserweb.mapper.CardisplacementMapper;
import com.woniuxy.carlife.carlifeuserweb.service.CardisplacementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:CardisplacementServiceImpl
 * @Description:
 * @date 2021/4/6 20:02
 **/

@Service
public class CardisplacementServiceImpl extends ServiceImpl<CardisplacementMapper, Cardisplacement> implements CardisplacementService {

    @Resource
    CardisplacementMapper cardisplacementMapper;

    /*
     * 功能描述〈查询所有汽车排量〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/10 19:56
     * @throws
     */

    @Override
    public List<Cardisplacement> findCardisplacement()  {
        QueryWrapper<Cardisplacement> cardisplacementQueryWrapper = new QueryWrapper<>();
        List<Cardisplacement> cardisplacements = cardisplacementMapper.selectList(cardisplacementQueryWrapper);
        return cardisplacements == null ? null : cardisplacements;
    }

    /*
     * 功能描述〈根据汽车排量id查询〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/10 19:56
     * @throws
     */

    @Override
    public Cardisplacement findCardisplacementById(String cardisplacementId) {
        QueryWrapper<Cardisplacement> cardisplacementQueryWrapper = new QueryWrapper<>();
        cardisplacementQueryWrapper.eq("carmodel_id", cardisplacementId);
        Cardisplacement cardisplacement = cardisplacementMapper.selectOne(cardisplacementQueryWrapper);
        return cardisplacement == null ? null : cardisplacement;
    }
}
